<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<script>
$(document).ready(function() {
    var max_fields      = 10; //maximum input boxes allowed
    var wrapper         = $(".input_fields_wrap"); //Fields wrapper
    var add_button      = $(".add_field_button"); //Add button ID
    
    var x = 1; //initlal text box count
    $(add_button).click(function(e){ //on add input button click
        e.preventDefault();
        if(x < max_fields){ //max input box allowed
            x++; //text box increment
            $(wrapper).append('<div><input type="text" onclick="openKCFinder(this)" placeholder="Tạo slide ảnh" style="cursor:pointer" class="form-control" name="slide_product[]"/><a href="#" class="remove_field">Remove</a></div>'); //add input box
        }
    });
    
    $(wrapper).on("click",".remove_field", function(e){ //user click on remove text
        e.preventDefault(); $(this).parent('div').remove(); x--;
    })
});
</script>
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        Quản lý slideshow
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i>Admins</a></li>
        <li><a href="#">slideshow</a></li>
      </ol>
    </section>
    <?php if($temp['mess']!='')
    {
    ?>
    <div class="pad margin no-print">
          <div style="margin-bottom: 0!important;" class="callout callout-info">												
                <?php echo $temp['mess']; ?>
          </div>
    </div>    
    <?php
    }
    ?>
    <!-- Main content -->
    <section class="content">
        <!-- form start -->
        <form role="form" method="POST">
            <input type="hidden" name="id" value="<?php echo  $firstArray['id']; ?>" /> 
            <div class="row">
                    <!-- left column -->
                    <div class="col-md-12">
                      <!-- general form elements -->
                      <div class="box box-primary">
                        <div class="box-header">
                          <h3 class="box-title">Chỉnh sửa slideshow</h3>
                        </div><!-- /.box-header -->
                          <div class="box-body">
                            <!-- Name cat -->
                            <div class="form-group">
                              <label>Tên slideshow</label>
                              <input type="text" class="form-control" value="<?php echo  $firstArray['name']; ?>" placeholder="Tên slideshow" name="name" />
                            </div>
                            <!-- Name cat -->
                            <div class="form-group">
                              <label>Link</label>
                              <input type="text" class="form-control" value="<?php echo  $firstArray['url']; ?>" placeholder="Link" name="url" />
                            </div>                                                    
                            <div class="form-group">
                              <label>Ảnh</label>
                            <?php
                                if($firstArray['photo'])
                                {
                                ?>
                                <p class="images_upload">
                                <input type="text" class="form-control" readonly="readonly" onclick="openKCFinder(this)"
    placeholder="Click để chọn ảnh" style="cursor:pointer" name="photo" value="<?php echo $firstArray['photo']; ?>" />     
                                <img width="50" id="photo_IMG" src="<?php echo ($firstArray['photo']?DOMAIN.$firstArray['photo']:DOMAIN."/access/images/no-images.jpg"); ?>" />
                                <i class="fa fa-times" id="photo"></i>
                                </p>
                                <?php
                                }
                                else
                                {
                                ?>
                                <input type="text" readonly="readonly" onclick="openKCFinder(this)" placeholder="Click để chọn ảnh" style="cursor:pointer" class="form-control" name="photo" />
                                <?php
                                }
                            ?>                              
                            </div>
                            <div class="checkbox">
                              <label>
                                <input type="checkbox" name="active" <?php echo (isset($firstArray['active'])==1?"checked='checked'":""); ?>  /> Cho phép hiển thị
                              </label>
                            </div>
                            <div class="box-footer">
                                <button class="btn btn-primary" type="submit">Đăng slideshow</button>
                            </div>                                                                                                                                                                         
                          </div><!-- /.box-body -->
                      </div><!-- /.box -->               
                    </div>            
            </div>          
        </form>        
    </section><!-- /.content -->
<script>
    $('form').validate({
        rules: {
       	    photo: {
                required: true
            }
        },
        highlight: function(element) {
            $(element).closest('.form-group').addClass('has-error');
        },
        unhighlight: function(element) {
            $(element).closest('.form-group').removeClass('has-error');
        },
        errorElement: 'span',
        errorClass: 'help-block',
        errorPlacement: function(error, element) {
            if(element.parent('.input-group').length) {
                error.insertAfter(element.parent());
            } else {
                error.insertAfter(element);
            }
        }
    });
    $(document).ready(function(){
        $("#photo").click(function(){
            var x;
            if (confirm("Bạn muốn xóa ảnh?") == true) {
                $(".images_upload input[name='photo']").val("");
                $( ".images_upload img#photo_IMG" ).remove();
            }
        });        
    });    
</script>             
</div><!-- /.content-wrapper -->